/*
 * Copyright 2020 www.mytijian.com All right reserved. This software is the
 * confidential and proprietary information of www.mytijian.com ("Confidential
 * Information"). You shall not disclose such Confidential Information and shall
 * use it only in accordance with the terms of the license agreement you entered
 * into with www.mytijian.com.
 */
package com.mytijian.task.selector;

import java.util.HashMap;
import java.util.Map;

public class WaitClient {
    private static Map<Integer, Object> lock = new HashMap<>();
    public static void main(String[] args) {
        lock.put(1, new Object());
        lock.put(2, new Object());
        lock.put(3, new Object());
        for (int i = 1; i<=3 ;i++) {
            notify(i);
        }
        for (int i = 1; i<=3 ;i++) {
            try {
                lock.get(i).wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        int i = 0;
    }
    public static void notify(int i) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Thread.sleep(5000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                lock.get(i).notifyAll();
            }
        }).start();
    }
}
